

#include "atomic_op_namespace.h"

#include <sys/atomic.h>

#ifdef __HAVE_ATOMIC64_OPS

void
atomic_dec_64(volatile uint64_t *addr)
{
	uint64_t old, new;

	do {
		old = *addr;
		new = old - 1;
	} while (atomic_cas_64(addr, old, new) != old);
}

#undef atomic_dec_64
atomic_op_alias(atomic_dec_64,_atomic_dec_64)

#if defined(_LP64)
#undef atomic_dec_ulong
atomic_op_alias(atomic_dec_ulong,_atomic_dec_64)
__strong_alias(_atomic_dec_ulong,_atomic_dec_64)

#undef atomic_dec_ptr
atomic_op_alias(atomic_dec_ptr,_atomic_dec_64)
__strong_alias(_atomic_dec_ptr,_atomic_dec_64)
#endif /* _LP64 */

#endif
